using JT808Protocol.Common;
using JT808Protocol.Models.Attributes;
using System.Text.Json.Serialization;

namespace JT808Protocol.Models.BodyParserStrategy.Location
{
    /// <summary>
    /// 报警状态位信息
    /// </summary>
    public class AlarmStatusBits
    {
        /// <summary>
        /// 紧急报警
        /// </summary>
        [JsonPropertyName("紧急报警")]
        [JsonBooleanString]
        public bool EmergencyAlarm { get; set; }

        /// <summary>
        /// 超速报警
        /// </summary>
        [JsonPropertyName("超速报警")]
        [JsonBooleanString]
        public bool OverSpeedAlarm { get; set; }

        /// <summary>
        /// 疲劳驾驶
        /// </summary>
        [JsonPropertyName("疲劳驾驶")]
        [JsonBooleanString]
        public bool TiredDriving { get; set; }

        /// <summary>
        /// 危险预警
        /// </summary>
        [JsonPropertyName("危险预警")]
        [JsonBooleanString]
        public bool DangerWarning { get; set; }

        /// <summary>
        /// GNSS模块发生故障
        /// </summary>
        [JsonPropertyName("GNSS模块发生故障")]
        [JsonBooleanString]
        public bool GnssModalError { get; set; }

        /// <summary>
        /// GNSS天线未接或被剪断
        /// </summary>
        [JsonPropertyName("GNSS天线未接或被剪断")]
        [JsonBooleanString]
        public bool GnssAntennaNoConn { get; set; }

        /// <summary>
        /// GNSS天线短路
        /// </summary>
        [JsonPropertyName("GNSS天线短路")]
        [JsonBooleanString]
        public bool GnssAntennaShortOut { get; set; }

        /// <summary>
        /// 终端主电源欠压
        /// </summary>
        [JsonPropertyName("终端主电源欠压")]
        [JsonBooleanString]
        public bool PowerLow { get; set; }

        /// <summary>
        /// 终端主电源掉电
        /// </summary>
        [JsonPropertyName("终端主电源掉电")]
        [JsonBooleanString]
        public bool PowerOff { get; set; }

        /// <summary>
        /// 终端LCD或显示器故障
        /// </summary>
        [JsonPropertyName("终端LCD或显示器故障")]
        [JsonBooleanString]
        public bool LcdError { get; set; }

        /// <summary>
        /// TTS模块故障
        /// </summary>
        [JsonPropertyName("TTS模块故障")]
        [JsonBooleanString]
        public bool TtsModalError { get; set; }

        /// <summary>
        /// 摄像头故障
        /// </summary>
        [JsonPropertyName("摄像头故障")]
        [JsonBooleanString]
        public bool CameraError { get; set; }

        /// <summary>
        /// 当天累计驾驶超时
        /// </summary>
        [JsonPropertyName("当天累计驾驶超时")]
        [JsonBooleanString]
        public bool DayDriverTimeOut { get; set; }

        /// <summary>
        /// 超时停车
        /// </summary>
        [JsonPropertyName("超时停车")]
        [JsonBooleanString]
        public bool StopTimeOut { get; set; }

        /// <summary>
        /// 进出区域
        /// </summary>
        [JsonPropertyName("进出区域")]
        [JsonBooleanString]
        public bool InOutArea { get; set; }

        /// <summary>
        /// 进出路线
        /// </summary>
        [JsonPropertyName("进出路线")]
        [JsonBooleanString]
        public bool InOutLine { get; set; }

        /// <summary>
        /// 路段行驶时间不足/过长
        /// </summary>
        [JsonPropertyName("路段行驶时间不足/过长")]
        [JsonBooleanString]
        public bool LineSectionDriverTimeLessOrMore { get; set; }

        /// <summary>
        /// 路线偏离报警
        /// </summary>
        [JsonPropertyName("路线偏离报警")]
        [JsonBooleanString]
        public bool LineDriftAlarm { get; set; }

        /// <summary>
        /// 车辆VSS故障
        /// </summary>
        [JsonPropertyName("车辆VSS故障")]
        [JsonBooleanString]
        public bool VehicleVSSError { get; set; }

        /// <summary>
        /// 车辆油量异常
        /// </summary>
        [JsonPropertyName("车辆油量异常")]
        [JsonBooleanString]
        public bool VehicleOilException { get; set; }

        /// <summary>
        /// 车辆被盗
        /// </summary>
        [JsonPropertyName("车辆被盗")]
        [JsonBooleanString]
        public bool VehicleStolen { get; set; }

        /// <summary>
        /// 车辆非法点火
        /// </summary>
        [JsonPropertyName("车辆非法点火")]
        [JsonBooleanString]
        public bool VehicleIllegalAccOn { get; set; }

        /// <summary>
        /// 车辆非法位移
        /// </summary>
        [JsonPropertyName("车辆非法位移")]
        [JsonBooleanString]
        public bool VehicleIllegalMove { get; set; }

        /// <summary>
        /// 碰撞预警
        /// </summary>
        [JsonPropertyName("碰撞预警")]
        [JsonBooleanString]
        public bool CrashAlarm { get; set; }

        /// <summary>
        /// 侧翻报警
        /// </summary>
        [JsonPropertyName("侧翻报警")]
        [JsonBooleanString]
        public bool FallAlarm { get; set; }

        /// <summary>
        /// 解析状态位
        /// </summary>
        public void ReadStatus(uint status)
        {
            //紧急报警
            EmergencyAlarm = ParseHelper.Bit(status, 0);
            //超速报警
            OverSpeedAlarm = ParseHelper.Bit(status, 1);
            //疲劳驾驶
            TiredDriving = ParseHelper.Bit(status, 2);
            //预警
            DangerWarning = ParseHelper.Bit(status, 3);
            //GNSS模块发生故障
            GnssModalError = ParseHelper.Bit(status, 4);
            //GNSS天线未接或被剪断
            GnssAntennaNoConn = ParseHelper.Bit(status, 5);
            //GNSS天线短路
            GnssAntennaShortOut = ParseHelper.Bit(status, 6);
            //终端主电源欠压
            PowerLow = ParseHelper.Bit(status, 7);
            //终端主电源掉电
            PowerOff = ParseHelper.Bit(status, 8);
            //终端LCD或显示器故障
            LcdError = ParseHelper.Bit(status, 9);
            //TTS模块故障
            TtsModalError = ParseHelper.Bit(status, 10);
            //摄像头故障
            CameraError = ParseHelper.Bit(status, 11);
            //当天累计驾驶超时
            DayDriverTimeOut = ParseHelper.Bit(status, 18);
            //超时停车
            StopTimeOut = ParseHelper.Bit(status, 19);
            //进出区域
            InOutArea = ParseHelper.Bit(status, 20);
            //进出路线
            InOutLine = ParseHelper.Bit(status, 21);
            //路段行驶时间不足/过长
            LineSectionDriverTimeLessOrMore = ParseHelper.Bit(status, 22);
            //路线偏离报警
            LineDriftAlarm = ParseHelper.Bit(status, 23);
            //车辆VSS故障
            VehicleVSSError = ParseHelper.Bit(status, 24);
            //车辆油量异常
            VehicleOilException = ParseHelper.Bit(status, 25);
            //车辆被盗
            VehicleStolen = ParseHelper.Bit(status, 26);
            //车辆非法点火
            VehicleIllegalAccOn = ParseHelper.Bit(status, 27);
            //车辆非法位移
            VehicleIllegalMove = ParseHelper.Bit(status, 28);
            //碰撞预警
            CrashAlarm = ParseHelper.Bit(status, 29);
            //碰撞侧翻报警
            FallAlarm = ParseHelper.Bit(status, 30);
        }
    }
}